﻿using System;

class Rectangle
{
    private double length;
    private double width;
    public Rectangle(double l, double w)
    {
        length = l;
        width = w;
    }

    public double Length
    {
        get { return length; }
        set { length = value; }
    }
    public double Width
    {
        get { return width; }
        set { width = value; }
    }
    public double CalculatePerimeter()
    {
        return 2 * (length + width);
    }
    public double CalculateArea()
    {
        return length * width;
    }

    public void Display()
    {
        Console.WriteLine($"长方形: 长度 = {length}, 宽度 = {width}, 周长 = {CalculatePerimeter()}, 面积 = {CalculateArea()}");
    }
}

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("长方形类测试程序");
        Console.WriteLine("==================");

        Rectangle rect1 = new Rectangle(5.0, 3.0);
        Rectangle rect2 = new Rectangle(7.5, 4.2);

        Console.WriteLine("\n第一个长方形:");
        rect1.Display();

        Console.WriteLine("\n第二个长方形:");
        rect2.Display();

        Console.WriteLine("\n修改第一个长方形的尺寸...");
        rect1.Length = 8.0;
        rect1.Width = 6.0;
        rect1.Display();

        Console.WriteLine("\n创建自定义长方形:");
        Console.Write("请输入长度: ");
        double l = Convert.ToDouble(Console.ReadLine());
        Console.Write("请输入宽度: ");
        double w = Convert.ToDouble(Console.ReadLine());

        Rectangle customRect = new Rectangle(l, w);
        customRect.Display();

        Console.WriteLine("\n按任意键退出...");
        Console.ReadKey();
    }
}